/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package de.aurelius.relations;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

/**
 *
 */
@Entity
@Table(name= "TRANSISTORS" , uniqueConstraints={@UniqueConstraint(columnNames="NAME", name="UNIQQNEZZ")})
public class Transistor implements Serializable {

    @Id
    private int id;

    @Column(name= "NAME")
    private String name;
    private boolean miniaturized;

    @ManyToOne
    @JoinColumn(name="MICROPROCESSOR_ID")
    private Microprocessor microprocessor;

    public Transistor() {

    }

    public Microprocessor getMicroprocessor() {
        return microprocessor;
    }

    public void setMicroprocessor(Microprocessor microprocessor) {
        this.microprocessor = microprocessor;
    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public boolean isMiniaturized() {
        return miniaturized;
    }

    public void setMiniaturized(boolean miniaturized) {
        this.miniaturized = miniaturized;
    }

    @Override
    public String toString() {
        return "Transistor{" + "id=" + id + ", name=" + name + ", miniaturized=" + miniaturized + ", microprocessor=" + microprocessor + '}';
    }


    @Override
    public int hashCode() {
        int hash = 5;
        hash = 97 * hash + (this.name != null ? this.name.hashCode() : 0);
        hash = 97 * hash + (this.miniaturized ? 1 : 0);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Transistor other = (Transistor) obj;
        if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
            return false;
        }
        if (this.miniaturized != other.miniaturized) {
            return false;
        }
        return true;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }


}
